// 快捷访问的作用
import { generateColor } from '../utils/theme'
import { getItem } from '../utils/storage'
import { MAIN_COLOR } from '../constant'
const getters = {
  token: (state: any) => {
    return state.user.token
  },
  accessToken: (state: any) => {
    return state.user.accessToken
  },
  refreshToken: (state: any) => {
    return state.user.refreshToken
  },
  /**
   * @returns true 表示用户信息已存在
   */
  hasUserInfo: (state: any) => {
    return JSON.stringify(state.user.userinfo) !== '{}'
  },
  userInfo: (state: any) => state.user.userinfo,
  sidebarOpened: (state: any) => state.app.sidebarOpened,
  cssVar: (state: any) => ({
    ...state.theme.variables,
    ...generateColor(getItem(MAIN_COLOR))
  }),
  language: (state: any) => state.app.language,
  tagsViewList: (state: any) => state.app.tagsViewList,
  mainColor: (state: any) => state.theme.mainColor
}
export default getters
